/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package justdoit.view;

import java.awt.Component;
//import java.awt.event.ActionEvent;
//import java.awt.event.KeyEvent;
import javax.swing.JCheckBoxMenuItem;
//import javax.swing.KeyStroke;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;
import justdoit.Startup;
import justdoit.actions.AboutAction;
import justdoit.actions.AddNewTaskAction;
import justdoit.actions.AddNewUserAction;
import justdoit.actions.AlwaysOnTopAction;
import justdoit.actions.ChangeUserAction;
import justdoit.actions.CompactViewAction;
import justdoit.actions.DeleteTaskAction;
import justdoit.actions.DeleteUserAction;
import justdoit.actions.EditAction;
import justdoit.actions.EditTaskAction;
import justdoit.actions.ExitAction;
import justdoit.actions.ExportAction;
import justdoit.actions.FileAction;
import justdoit.actions.HelpAction;
import justdoit.actions.HelpHelpAction;
import justdoit.actions.ImportAction;
import justdoit.actions.MarkAsDoneAction;
import justdoit.actions.ShowStatusBarAction;
import justdoit.actions.UserAction;
import justdoit.actions.UserSettingsAction;
import justdoit.actions.ViewAction;
import justdoit.controller.LanguageManager;
import justdoit.model.DefaultSettings;

/**
 * The MenuBar on the main window "MainFrame".
 * @author Can, edited by Dilshod
 */
public class TaskMenuBar extends JMenuBar {

    private JMenu[] menuOption = {
        new JMenu(new FileAction()),
        new JMenu(new EditAction()),
        new JMenu(new ViewAction()),
        new JMenu(new UserAction()),
        new JMenu(new HelpAction())};
    private Component[] fileItems = {
        new JMenuItem(new ImportAction()),
        new JMenuItem(new ExportAction()),
        new JSeparator(),
        new JMenuItem(new ExitAction())
    };
    private Component[] editItems = {
        new JMenuItem(new AddNewTaskAction()),
        new JMenuItem(new EditTaskAction()),
        new JMenuItem(new DeleteTaskAction()),
        new JSeparator(),
        new JMenuItem(new MarkAsDoneAction())
    };
    private Component[] viewItems = {
        new JMenuItem(new CompactViewAction()),
        new JCheckBoxMenuItem(new AlwaysOnTopAction()),
        new JCheckBoxMenuItem(new ShowStatusBarAction())
    };
    private Component[] userItems = {
        new JMenuItem(new AddNewUserAction()),
        new JMenuItem(new ChangeUserAction()),
        new JMenuItem(new DeleteUserAction()),
        new JSeparator(),
        new JMenuItem(new UserSettingsAction())
    };
    private Component[] helpItems = {
        new JMenuItem(new HelpHelpAction()),
        new JMenuItem(new AboutAction())
    };

    public TaskMenuBar() {
        for (Component fi : fileItems) {
            menuOption[0].add(fi);
        }
        for (Component ei : editItems) {
            menuOption[1].add(ei);
        }
        for (Component vi : viewItems) {
            menuOption[2].add(vi);
        }
        for (Component usi : userItems) {
            menuOption[3].add(usi);
        }
        for (Component hi : helpItems) {
            menuOption[4].add(hi);
        }

        for (JMenu m : menuOption) {
            this.add(m);
        }

        if (Startup.getDs().getMode().equals(DefaultSettings.MODE_COMPACT)) {
            ((JMenuItem) viewItems[0]).setText(LanguageManager.getString("menu.view.normal"));
        } else {
            ((JMenuItem) viewItems[0]).setText(LanguageManager.getString("menu.view.compact"));
        }

    }
}
